package com.docking.heylo.web.controller;

import com.docking.heylo.service.ISysDictService;
import com.docking.heylo.web.dto.AppointmentConfDto;
import com.docking.heylo.web.utils.ResultUtil;
import com.docking.heylo.web.vo.BaseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/***
 * 系统配置管理器
 */
@RestController
@RequestMapping("/sysDict")
public class SysDictController {

    @Autowired
    private ISysDictService sysDictService;

    /***
     * 配置约拍价格
     *
     * @param confDto
     * @return
     */
    @PostMapping(value = "appointmentConf")
    public BaseVo appointmentConf(@RequestBody @Validated AppointmentConfDto confDto){
        sysDictService.appointmentConf(confDto);
        return ResultUtil.success("配置成功");
    }


    /***
     * 配置约拍价格
     *
     * @return
     */
    @PostMapping(value = "appointmentConfDetail")
    public BaseVo appointmentConfDetail(){
        Map<String, Object> conf = sysDictService.appointmentConfDetail();

        return ResultUtil.success("成功", new HashMap<String, Object>(){{
            put("startingPrice", conf.get("starting_price"));
            put("refinedPrice", conf.get("refined_price"));
            put("platformDiscount", conf.get("platform_discount"));
            put("baseTime", conf.get("base_time"));
            put("overtimeUnitPrice", conf.get("overtime_unit_price"));
            put("rake", conf.get("rake"));
            put("platformRemark", get("platform_remark"));
        }});
    }








}
